Skip to content

gh-88831: In docs for asyncio.create_task, explain why strong references to tasks are needed#93258

Merged
ambv merged 4 commits intopython:mainfrom
agrommek:augment_asyncio_create_task_docs
Jun 7, 2022
Merged

gh-88831: In docs for asyncio.create_task, explain why strong references to tasks are needed#93258
ambv merged 4 commits intopython:mainfrom
agrommek:augment_asyncio_create_task_docs

Conversation

@agrommek
Copy link
Contributor

Hello everybody,

this is a small PR augmenting the documentation of asyncio.create_task(). The documentation states that one has to keep a reference to all running tasks, but most of the time it also works when you don't. This led to a bit of head-scratching on my part (see https://stackoverflow.com/questions/71938799/python-asyncio-create-task-really-need-to-keep-a-reference) until I discovered #88831 (which led me to create this PR to solve this issue).

If accepted, this PR should probably be backported to versions starting from 3.7, i.e. all versions having asyncio.create_task().

This PR might have relevance for issue #91887: If the asyncio event loop keeps strong references itself one day, the information added with this PR can be removed again.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants